﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using Final.App_Code;
using System.Data;

namespace Final
{
     
    public partial class student_allocation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                studentnameListbox.SelectedIndex = -1;
            }                
        }

        protected void approveButton_Click(object sender, EventArgs e)
        {

            Student cs = new Student();
            cs.Adminno = lbl_adminNo.Text;
            cs.Module = subjectddl.SelectedItem.ToString();

            Studentsubject_allocation.updateStudentInfo(cs);

            string alertScript = String.Format("<Script Language='javascript'> alert('{0}');</script>", "Assigned Succesfully");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Key", alertScript, false);

            
        }

        protected void studentnameListbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Student cs = Change_subjDataClass.GetStudentInfo(studentnameListbox.SelectedValue.ToString());
            Studentsubject_allocation p = new Studentsubject_allocation();
            Studentsubject_allocation.getsubmittedtime(studentnameListbox.SelectedValue.ToString());
            
            lbl_adminNo.Text = cs.Adminno;
            lbl_name.Text = cs.Name;
            lbl_courseName.Text = cs.Coursename;
            lbl_coursecode.Text = cs.Coursecode;
            lbl_module.Text = cs.Module;
            lbl_contactNo.Text = Convert.ToString(cs.Contact);
            lbl_email.Text = cs.Email;
            lbl_submittedtime.Text = Studentsubject_allocation.getsubmittedtime(cs.Adminno).ToString("MM/dd/yyyy hh:mm:ss tt");
           
            Session["student"] = studentnameListbox.SelectedValue;
            subjectddl.DataBind();
        }     
    }
}